package com.ruoyi.system.myweb.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.myweb.domain.TheaterTable;
import com.ruoyi.system.myweb.service.ITheaterTableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 影院列表Controller
 * 
 * @author zyh
 * @date 2024-05-21
 */
@RestController
@RequestMapping("/theater/ttheater_table")
public class TheaterTableController extends BaseController
{
    @Autowired
    private ITheaterTableService theaterTableService;

    /**
     * 查询影院列表列表
     */
    @PreAuthorize("@ss.hasPermi('theater:ttheater_table:list')")
    @GetMapping("/list")
    public TableDataInfo list(TheaterTable theaterTable)
    {
        startPage();
        List<TheaterTable> list = theaterTableService.selectTheaterTableList(theaterTable);
        return getDataTable(list);
    }

    /**
     * 导出影院列表列表
     */
    @PreAuthorize("@ss.hasPermi('theater:ttheater_table:export')")
    @Log(title = "影院列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TheaterTable theaterTable)
    {
        List<TheaterTable> list = theaterTableService.selectTheaterTableList(theaterTable);
        ExcelUtil<TheaterTable> util = new ExcelUtil<TheaterTable>(TheaterTable.class);
        util.exportExcel(response, list, "影院列表数据");
    }

    /**
     * 获取影院列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('theater:ttheater_table:query')")
    @GetMapping(value = "/{theaterId}")
    public AjaxResult getInfo(@PathVariable("theaterId") Long theaterId)
    {
        return success(theaterTableService.selectTheaterTableByTheaterId(theaterId));
    }

    /**
     * 新增影院列表
     */
    @PreAuthorize("@ss.hasPermi('theater:ttheater_table:add')")
    @Log(title = "影院列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TheaterTable theaterTable)
    {
        return toAjax(theaterTableService.insertTheaterTable(theaterTable));
    }

    /**
     * 修改影院列表
     */
    @PreAuthorize("@ss.hasPermi('theater:ttheater_table:edit')")
    @Log(title = "影院列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TheaterTable theaterTable)
    {
        return toAjax(theaterTableService.updateTheaterTable(theaterTable));
    }

    /**
     * 删除影院列表
     */
    @PreAuthorize("@ss.hasPermi('theater:ttheater_table:remove')")
    @Log(title = "影院列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{theaterIds}")
    public AjaxResult remove(@PathVariable Long[] theaterIds)
    {
        return toAjax(theaterTableService.deleteTheaterTableByTheaterIds(theaterIds));
    }
}
